var task1 = new Promise(function (resolve, reject) {
  resolve(100)
})

var task2 = new Promise(function (resolve, reject) {
  resolve(200)
})

const task3 = new Promise(function (resolve, reject) {
  reject(new Error('rejected'))
})

var promise1 = Promise.all([
  task1,
  task2,
])

promise1.then(val => {
  console.log(val)
}).catch(error => {
  console.log(error)
})

var promise2 = Promise.race([
  task1,
  task2,
  task3
])

promise2.then(val => {
  console.log(val)
}).catch(error => {
  console.log(error)
})